package com.storm.data;

import java.io.Serializable;

/**
 * this class used to save the particle table we got,
 * @author liuquan
 * @date 2013-11-28
 *
 */
public class ParticleTable implements Cloneable, Serializable{

	private static final long serialVersionUID = 1L;
	public static int MAX_COLUMN = 30;//the max column we can save
	private double[][] table;//we use this double dimensional array to save the real data we got
	private String[] headings;//the headings of the table,we have 18 default columns
	private String[] defaultHeadings = {"point count","Intensity","X (px)","Y (px)","X (nm)","Y (nm)","Z (nm)","Left-Width (px)","Right-Width (px)","Up-Height (px)","Down-Height (px)","X Symmetry (%)","Y Symmetry (%)","Width minus Height (px)","Frame Number","Color","Photon Count"};
	private int curRow;//the current count of row
	private int columnCount = 0;//the current count of column
	
	public ParticleTable(){
		headings = new String[MAX_COLUMN];
	}
	public ParticleTable(String[] headings){
		headings = new String[MAX_COLUMN];
		for(int i=0;i<headings.length;i++){
			this.headings[i] = headings[i];
			columnCount ++;
		}
	}
	
	/**
	 * reset the headings of the particle table to default headings
	 */
	public void resetDefaultHeadings(){
		int i = 0; 
		for(;i<defaultHeadings.length;i++){
			this.headings[i] = defaultHeadings[i];
		}
		for(;i<headings.length;i++){
			this.headings[i] = "";
		}
	}

	/**
	 * reset the headings of the particle table to empty 
	 */
	public void resetEmptyHeadings(){
		for(int i=0;i<headings.length;i++){
			headings[i] = "";
		}
	}
	
	/**
	 * add a new heading to the table 
	 * @param heading
	 */
	public void addHeading(String heading){
		for(int i=0;i<columnCount;i++){
			if(headings[i].equals(heading)){
				//TODO here we add one log
				return;
			}
		}
		headings[columnCount++] = heading;
	}
}
